<<<<<<< HEAD
#include <stdio.h>
#include "../../src/coreServer/TCP_Master.h" // 包含 TCP 服务器的头文件
#include "../../src/memoryPool/e_palloc.h"
#include "../../src/connectionManger/connectionManger.h"
#include "../../src/threadPool/thread_pool.h"
/**
 * @brief 程序主入口
 *
 * @param argc 参数数量
 * @param argv 参数值
 * @return int 退出码
 */

//申请一个内存池
struct mp_pool_s *m_mp = NULL;
ConnectionManger m_conn_manager = {0};
ThreadPool *m_thread_pool = NULL;

#define THREAD_POOL_THREADS 8
#define THREAD_POOL_QUEUE_SIZE 1024

int main(int argc, char *argv[]) {

    printf("Initializing memory pool...\n");
    m_mp = mp_create_pool(PAGE_SIZE);
    if (!m_mp) {
        fprintf(stderr, "Failed to create memory pool.\n");
        return -1;
    }

    printf("Initializing connection manager...\n");
    if (connection_manger_init() != 0) {
        fprintf(stderr, "Failed to initialize connection manager.\n");
        mp_destroy_pool(m_mp);
        return -1;
    }

    printf("Initializing thread pool...\n");
    m_thread_pool = thread_pool_init(THREAD_POOL_THREADS, THREAD_POOL_QUEUE_SIZE);
    if (!m_thread_pool) {
        fprintf(stderr, "Failed to initialize thread pool.\n");
        connection_manger_destroy();
        mp_destroy_pool(m_mp);
        return -1;
    }


    printf("正在启动 Epoll TCP 服务器...\n");

    pthread_t connectionManger_thread;

    // 调用 Init_tcp_server() 函数来启动服务器。
    // 注意：根据 TCP_Master.c 中的定义，此函数是 _Noreturn 的，
    // 它会进入一个无限循环来处理网络事件，永远不会返回。
    Init_tcp_server();

    // 因此，这行代码在正常情况下永远不会被执行。
    printf("Server shutting down.\n");
    thread_pool_destroy(m_thread_pool);
    connection_manger_destroy();
    mp_destroy_pool(m_mp);

    return 0;
}
=======
#include <stdio.h>
#include "../../src/coreServer/TCP_Master.h" // 包含 TCP 服务器的头文件
#include "../../src/memoryPool/e_palloc.h"
#include "../../src/connectionManger/connectionManger.h"
#include "../../src/threadPool/thread_pool.h"
/**
 * @brief 程序主入口
 *
 * @param argc 参数数量
 * @param argv 参数值
 * @return int 退出码
 */

#define DEBUG 1

//申请一个内存池
struct mp_pool_s *m_mp = NULL;
ConnectionManger m_conn_manager = {0};
ThreadPool *m_thread_pool = NULL;

#define THREAD_POOL_THREADS 8
#define THREAD_POOL_QUEUE_SIZE 1024

int main() {

    printf("Initializing memory pool...\n");
    m_mp = mp_create_pool(PAGE_SIZE);
    if (!m_mp) {
        fprintf(stderr, "Failed to create memory pool.\n");
        return -1;
    }

    printf("Initializing connection manager...\n");
    if (connection_manager_init() != 0) {
        fprintf(stderr, "Failed to initialize connection manager.\n");
        mp_destroy_pool(m_mp);
        return -1;
    }

    printf("Initializing thread pool...\n");
    m_thread_pool = thread_pool_init(THREAD_POOL_THREADS, THREAD_POOL_QUEUE_SIZE);
    if (!m_thread_pool) {
        fprintf(stderr, "Failed to initialize thread pool.\n");
        connection_manager_destroy();
        mp_destroy_pool(m_mp);
        return -1;
    }


    printf("正在启动 Epoll TCP 服务器...\n");

    //pthread_t connectionManger_thread;

    // 调用 Init_tcp_server() 函数来启动服务器。
    // 注意：根据 TCP_Master.c 中的定义，此函数是 _Noreturn 的，
    // 它会进入一个无限循环来处理网络事件，永远不会返回。
    Init_tcp_server();

    // 因此，这行代码在正常情况下永远不会被执行。
    printf("Server shutting down.\n");
    thread_pool_destroy(m_thread_pool);
    connection_manager_destroy();
    mp_destroy_pool(m_mp);

    return 0;
}
>>>>>>> bb0ff9c3c2755fe1d4c5931ceda14b42a0f05eed
